package design_mode.singleton;

/**
 * Created mangcao with 2019/5/31 11:11
 * Description: 懒汉模式 单例
 */
public class LazySingleton
{

    // 指令重排序
    private static volatile LazySingleton lazySingleton;

    private LazySingleton(){}

    // 粗粒度的锁
    public synchronized static LazySingleton getInstance() {
        if (lazySingleton == null) {
            lazySingleton = new LazySingleton();
        }
        return lazySingleton;
    }

}
